/*********************************************************************
*                                                                    *
*                SEGGER Microcontroller GmbH & Co. KG                *
*        Solutions for real time microcontroller applications        *
*                                                                    *
**********************************************************************
*                                                                    *
* C-file generated by:                                               *
*                                                                    *
*        GUI_Builder for emWin version 5.22                          *
*        Compiled Jul  4 2013, 15:16:01                              *
*        (c) 2013 Segger Microcontroller GmbH & Co. KG               *
*                                                                    *
**********************************************************************
*                                                                    *
*        Internet: www.segger.com  Support: support@segger.com       *
*                                                                    *
**********************************************************************
*/

#include "My_GUI_CB.h"

/*********************************************************************
*
*       My_Dialog_hWin handle
*/

WM_HWIN My_Menu_hWin;
WM_HWIN My_Data_hWin;
WM_HWIN My_Uart_hWin;

/*********************************************************************
*
*       Static code
*
**********************************************************************
*/

/*********************************************************************
*
*       My_Data_GUI Defines
*
**********************************************************************
*/
#define My_Data_ID_FRAMEWIN_0   (GUI_ID_USER + 0x00)
#define My_Data_ID_BUTTON_0     (GUI_ID_USER + 0x01)
#define My_Data_ID_BUTTON_1     (GUI_ID_USER + 0x02)
#define My_Data_ID_BUTTON_2     (GUI_ID_USER + 0x03)
#define My_Data_ID_BUTTON_3     (GUI_ID_USER + 0x04)
#define My_Data_ID_GRAPH_0      (GUI_ID_USER + 0x05)
#define My_Data_ID_EDIT_0       (GUI_ID_USER + 0x06)
#define My_Data_ID_TEXT_0       (GUI_ID_USER + 0x07)
#define My_Data_ID_TEXT_1       (GUI_ID_USER + 0x08)
#define My_Data_ID_EDIT_1       (GUI_ID_USER + 0x09)

/*********************************************************************
*
*       My_Uart_GUI Defines
*
**********************************************************************
*/
#define My_Uart_GUI_ID_USER      (GUI_ID_USER + 0x0A)
#define My_Uart_ID_FRAMEWIN_0    (My_Uart_GUI_ID_USER + 0x00)
#define My_Uart_ID_BUTTON_0      (My_Uart_GUI_ID_USER + 0x01)
#define My_Uart_ID_BUTTON_1      (My_Uart_GUI_ID_USER + 0x02)
#define My_Uart_ID_BUTTON_2      (My_Uart_GUI_ID_USER + 0x03)
#define My_Uart_ID_BUTTON_3      (My_Uart_GUI_ID_USER + 0x04)
#define My_Uart_ID_MULTIEDIT_0   (My_Uart_GUI_ID_USER + 0x05)
#define My_Uart_ID_MULTIEDIT_1   (My_Uart_GUI_ID_USER + 0x06)
#define My_Uart_ID_CHECKBOX_0    (My_Uart_GUI_ID_USER + 0x07)
#define My_Uart_ID_EDIT_0        (My_Uart_GUI_ID_USER + 0x08)
#define My_Uart_ID_EDIT_1        (My_Uart_GUI_ID_USER + 0x09)
#define My_Uart_ID_TEXT_0        (My_Uart_GUI_ID_USER + 0x0A)
#define My_Uart_ID_TEXT_1        (My_Uart_GUI_ID_USER + 0x0B)

/*********************************************************************
*
*       My_Menu_GUI Defines
*
**********************************************************************
*/
#define My_Menu_GUI_ID_USER     (My_Uart_GUI_ID_USER + 0x0C)
#define My_Menu_ID_FRAMEWIN_0   (My_Menu_GUI_ID_USER + 0x00)
#define My_Menu_ID_BUTTON_0     (My_Menu_GUI_ID_USER + 0x03)
#define My_Menu_ID_BUTTON_1     (My_Menu_GUI_ID_USER + 0x04)
// USER START (Optionally insert additional defines)
// USER END

/*********************************************************************
*
*       Static data
*
**********************************************************************
*/

// USER START (Optionally insert additional static data)
// USER END

/*********************************************************************
*
*       My_Data_aDialogCreate
*/
const GUI_WIDGET_CREATE_INFO My_Data_aDialogCreate[] = {
  { FRAMEWIN_CreateIndirect, "My_Data_GUI",  My_Data_ID_FRAMEWIN_0, 0,   0,   320, 240, 0, 0x0,  0 },
  { BUTTON_CreateIndirect,   "Enter",        My_Data_ID_BUTTON_0,   5,   201, 70,  20,  0, 0x0,  0 },
  { BUTTON_CreateIndirect,   "UP",           My_Data_ID_BUTTON_1,   80,  201, 70,  20,  0, 0x0,  0 },
  { BUTTON_CreateIndirect,   "Down",         My_Data_ID_BUTTON_2,   160, 201, 70,  20,  0, 0x0,  0 },
  { BUTTON_CreateIndirect,   "Exit",         My_Data_ID_BUTTON_3,   235, 201, 70,  20,  0, 0x0,  0 },
  { GRAPH_CreateIndirect,    "Graph",        My_Data_ID_GRAPH_0,    0,   0,   310, 180, 0, 0x0,  0 },
  { EDIT_CreateIndirect,     "Edit",         My_Data_ID_EDIT_0,     80,  182, 70,  18,  0, 0x64, 0 },
  { TEXT_CreateIndirect,     "AD X:",        My_Data_ID_TEXT_0,     0,   182, 80,  20,  0, 0x0,  0 },
  { TEXT_CreateIndirect,     "AD Y:",        My_Data_ID_TEXT_1,     160, 182, 80,  20,  0, 0x0,  0 },
  { EDIT_CreateIndirect,     "Edit",         My_Data_ID_EDIT_1,     235, 182, 70,  18,  0, 0x64, 0 },
  // USER START (Optionally insert additional widgets)
  // USER END
};
/*********************************************************************
*
*       My_Uart_aDialogCreate
*/
const GUI_WIDGET_CREATE_INFO My_Uart_aDialogCreate[] = {
  { FRAMEWIN_CreateIndirect,"My_Uart_GUI",My_Uart_ID_FRAMEWIN_0,  0,   0,   320, 240, 0, 0x0,  0 },
  { BUTTON_CreateIndirect, "Enter",       My_Uart_ID_BUTTON_0,    5,   201, 70,  20,  0, 0x0,  0 },
  { BUTTON_CreateIndirect, "UP",          My_Uart_ID_BUTTON_1,    80,  201, 70,  20,  0, 0x0,  0 },
  { BUTTON_CreateIndirect, "Down",        My_Uart_ID_BUTTON_2,    160, 201, 70,  20,  0, 0x0,  0 },
  { BUTTON_CreateIndirect, "Exit",        My_Uart_ID_BUTTON_3,    235, 201, 70,  20,  0, 0x0,  0 },
  { MULTIEDIT_CreateIndirect, "RXBuffer", My_Uart_ID_MULTIEDIT_0, 0,   0,   150, 180, 0, 0x0,  0 },
  { MULTIEDIT_CreateIndirect, "TxlBuffer",My_Uart_ID_MULTIEDIT_1, 160, 0,   150, 180, 0, 0x0,  0 },
  { CHECKBOX_CreateIndirect, "Openkbox",  My_Uart_ID_CHECKBOX_0,  230, 182, 82,  18,  0, 0x0,  0 },
  { EDIT_CreateIndirect, "Baudrate",      My_Uart_ID_EDIT_0,      32,  182, 70,  18,  0, 0x64, 0 },
  { EDIT_CreateIndirect, "Bit",           My_Uart_ID_EDIT_1,      146, 182, 70,  18,  0, 0x64, 0 },
  { TEXT_CreateIndirect, "Baud:",         My_Uart_ID_TEXT_0,      0,   182, 30,  20,  0, 0x0,  0 },
  { TEXT_CreateIndirect, "Byte:",         My_Uart_ID_TEXT_1,      114, 182, 30,  20,  0, 0x0,  0 },
  // USER START (Optionally insert additional widgets)
  // USER END
};

/*********************************************************************
*
*       My_Menu_aDialogCreate
*/
const GUI_WIDGET_CREATE_INFO My_Menu_aDialogCreate[] = {
  { FRAMEWIN_CreateIndirect, "Menu",  My_Menu_ID_FRAMEWIN_0, 0,  0,  320, 240, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "My_Data", My_Menu_ID_BUTTON_0,   0,  0,  80,  30,  0, 0x0, 0 },
  { BUTTON_CreateIndirect, "My_Uart", My_Menu_ID_BUTTON_1,   100, 0, 80,  30,  0, 0x0, 0 },
  // USER START (Optionally insert additional widgets)
  // USER END
};



// USER START (Optionally insert additional static code)
// USER END
static void My_Menu_cbDialog(WM_MESSAGE * pMsg) ;
static void My_Data_cbDialog(WM_MESSAGE * pMsg) ;
static void My_Uart_cbDialog(WM_MESSAGE * pMsg) ;
/*********************************************************************
*
*       My_Data_cbDialog
*/
static void My_Data_cbDialog(WM_MESSAGE * pMsg) {
  WM_HWIN hItem;
  int     NCode;
  int     Id;
  // USER START (Optionally insert additional variables)
  // USER END

  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
    //
    // Initialization of 'Edit'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, My_Data_ID_EDIT_0);
    EDIT_SetText(hItem, "123");
    //
    // Initialization of 'Edit'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, My_Data_ID_EDIT_1);
    EDIT_SetText(hItem, "123");
    // USER START (Optionally insert additional code for further widget initialization)
    // USER END
    break;
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;
    switch(Id) {
    case My_Data_ID_BUTTON_0: // Notifications sent by 'Enter'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case My_Data_ID_BUTTON_1: // Notifications sent by 'UP'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case My_Data_ID_BUTTON_2: // Notifications sent by 'Down'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case My_Data_ID_BUTTON_3: // Notifications sent by 'Exit'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
				{
					  GUI_Delay(10);
						GUI_EndDialog(My_Data_hWin,0);
						My_Menu_hWin = GUI_CreateDialogBox(My_Menu_aDialogCreate, GUI_COUNTOF(My_Menu_aDialogCreate), My_Menu_cbDialog, WM_HBKWIN, 0, 0);	
				}
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case My_Data_ID_EDIT_0: // Notifications sent by 'Edit'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case My_Data_ID_EDIT_1: // Notifications sent by 'Edit'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    // USER START (Optionally insert additional code for further Ids)
    // USER END
    }
    break;
  // USER START (Optionally insert additional message handling)
  // USER END
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}
/*********************************************************************
*
*       My_Uart_cbDialog
*/
static void My_Uart_cbDialog(WM_MESSAGE * pMsg) {
  WM_HWIN hItem;
  int     NCode;
  int     Id;
  // USER START (Optionally insert additional variables)
  // USER END

  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
    //
    // Initialization of 'RXBuffer'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, My_Uart_ID_MULTIEDIT_0);
    MULTIEDIT_SetText(hItem, "Multiedit");
    //
    // Initialization of 'TxlBuffer'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, My_Uart_ID_MULTIEDIT_1);
    MULTIEDIT_SetText(hItem, "Multiedit");
    //
    // Initialization of 'Openkbox'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, My_Uart_ID_CHECKBOX_0);
    CHECKBOX_SetText(hItem, "Open/Close");
    //
    // Initialization of 'Baudrate'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, My_Uart_ID_EDIT_0);
    EDIT_SetText(hItem, "115200");
    //
    // Initialization of 'Bit'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, My_Uart_ID_EDIT_1);
    EDIT_SetText(hItem, "7");
    // USER START (Optionally insert additional code for further widget initialization)
    // USER END
    break;
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;
    switch(Id) {
    case My_Uart_ID_BUTTON_0: // Notifications sent by 'Enter'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case My_Uart_ID_BUTTON_1: // Notifications sent by 'UP'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case My_Uart_ID_BUTTON_2: // Notifications sent by 'Down'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case My_Uart_ID_BUTTON_3: // Notifications sent by 'Exit'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
			  {
					  GUI_Delay(10);
						GUI_EndDialog(My_Uart_hWin,0);
						My_Menu_hWin = GUI_CreateDialogBox(My_Menu_aDialogCreate, GUI_COUNTOF(My_Menu_aDialogCreate), My_Menu_cbDialog, WM_HBKWIN, 0, 0);	
				}
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case My_Uart_ID_MULTIEDIT_0: // Notifications sent by 'RXBuffer'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case My_Uart_ID_MULTIEDIT_1: // Notifications sent by 'TxlBuffer'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case My_Uart_ID_CHECKBOX_0: // Notifications sent by 'Openkbox'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case My_Uart_ID_EDIT_0: // Notifications sent by 'Baudrate'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case My_Uart_ID_EDIT_1: // Notifications sent by 'Bit'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    // USER START (Optionally insert additional code for further Ids)
    // USER END
    }
    break;
  // USER START (Optionally insert additional message handling)
  // USER END
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}
/*********************************************************************
*
*       My_Menu_cbDialog
*/
static void My_Menu_cbDialog(WM_MESSAGE * pMsg) 
{
  int NCode;
  int Id;
  // USER START (Optionally insert additional variables)
  // USER END

  switch (pMsg->MsgId) 
	{
    case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;
    switch(Id) 
	  {
      case My_Menu_ID_BUTTON_0: // Notifications sent by 'Enter'
				switch(NCode) 
				{
					case WM_NOTIFICATION_CLICKED:
					// USER START (Optionally insert code for reacting on notification message)
						//My_Menu_ID_BUTTON_0_CLICKED_CB();
						{
				    	  GUI_Delay(10);
							  GUI_EndDialog(My_Menu_hWin,0);
								My_Data_hWin = GUI_CreateDialogBox(My_Data_aDialogCreate,
 							                                     GUI_COUNTOF(My_Data_aDialogCreate),
                                      						 My_Data_cbDialog, WM_HBKWIN, 0, 0);
						}
					// USER END
					break;
					case WM_NOTIFICATION_RELEASED:
					// USER START (Optionally insert code for reacting on notification message)
					
					// USER END
					break;
				  // USER START (Optionally insert additional code for further notification handling)
				  // USER END
				}
				break;
			case My_Menu_ID_BUTTON_1: // Notifications sent by 'UP'
				switch(NCode) 
				{
					case WM_NOTIFICATION_CLICKED:
					// USER START (Optionally insert code for reacting on notification message)
						{
			   		  GUI_Delay(10);
							GUI_EndDialog(My_Menu_hWin,0);
							My_Uart_hWin = GUI_CreateDialogBox(My_Uart_aDialogCreate, 
							                                   GUI_COUNTOF(My_Uart_aDialogCreate), 
							                                   My_Uart_cbDialog, WM_HBKWIN, 0, 0);		
						}
					// USER END
					break;
					case WM_NOTIFICATION_RELEASED:
					// USER START (Optionally insert code for reacting on notification message)
					// USER END
					break;
				// USER START (Optionally insert additional code for further notification handling)
				// USER END
				}
      break;
		// USER START (Optionally insert additional message handling)
		// USER END
		default:
			WM_DefaultProc(pMsg);
			break;
		}
  }
}

/*********************************************************************
*
*       Public code
*
**********************************************************************
*/
/*********************************************************************
*
*       CreateMy_Board_GUI
*/

WM_HWIN CreateMy_Board_GUI(void) 
{

	WM_SetCreateFlags(WM_CF_MEMDEV); 
	/* Use memory devices on all windows to avoid flicker */
	
	My_Menu_hWin = GUI_CreateDialogBox(My_Menu_aDialogCreate, GUI_COUNTOF(My_Menu_aDialogCreate), My_Menu_cbDialog, WM_HBKWIN, 0, 0);	
	
	

	while(1)
	{
		GUI_Delay(100);
		
	}
}

// USER START (Optionally insert additional public code)
// USER END

/*************************** End of file ****************************/
